import datetime
import asyncio
# 定时器任务计划
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from utils.decorator import singleton


@singleton
class MyScheduler(object):

    def __init__(self) -> None:
        self.scheduler = AsyncIOScheduler()
        self.scheduler.configure()
        print("启动调度器...")
        # self.scheduler.add_job(tick, 'interval', seconds=3)

    def start(self):
        self.scheduler.start()

    def pause(self):
        self.scheduler.pause()


async def tick():
    print('Tick! The time is: %s' % datetime.datetime.now())
    await asyncio.sleep(1)
